package com.bwie.bargain.service.impl;

import com.bwie.bargain.vo.BargainVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.Query;

import com.bwie.bargain.dao.BargainDao;
import com.bwie.bargain.entity.BargainEntity;
import com.bwie.bargain.service.BargainService;


@Service("bargainService")
public class BargainServiceImpl extends ServiceImpl<BargainDao, BargainEntity> implements BargainService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<BargainEntity> wrapper = new QueryWrapper<>();
        String key = (String) params.get("key");
        if (StringUtils.isNotEmpty(key)){
            wrapper.and(w->{
                w.eq("goods_id",key);
            });
        }
        IPage<BargainEntity> page = this.page(
                new Query<BargainEntity>().getPage(params),
                wrapper

        );

        return new PageUtils(page);
    }

    @Override
    public List<BargainVo> mslist() {

        return baseMapper.mslist();
    }

}